//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS BCMDataExports service.
///
/// You can use the Data Exports API to create customized exports from multiple Amazon Web Services cost management and billing datasets, such as cost and usage data and cost optimization recommendations. The Data Exports API provides the following endpoint:   https://bcm-data-exports.us-east-1.api.aws
public struct BCMDataExports: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the BCMDataExports client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            amzTarget: "AWSBillingAndCostManagementDataExports",
            serviceName: "BCMDataExports",
            serviceIdentifier: "bcm-data-exports",
            serviceProtocol: .json(version: "1.1"),
            apiVersion: "2023-11-26",
            endpoint: endpoint,
            errorType: BCMDataExportsErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Creates a data export and specifies the data query, the delivery preference, and any optional resource tags. A DataQuery consists of both a QueryStatement and TableConfigurations. The QueryStatement is an SQL statement. Data Exports only supports a limited subset of the SQL syntax. For more information on the SQL syntax that is supported, see Data query. To view the available tables and columns, see the Data Exports table dictionary. The TableConfigurations is a collection of specified TableProperties for the table being queried in the QueryStatement. TableProperties are additional configurations you can provide to change the data and schema of a table. Each table can have different TableProperties. However, tables are not required to have any TableProperties. Each table property has a default value that it assumes if not specified. For more information on table configurations, see Data query. To view the table properties available for each table, see the Data Exports table dictionary or use the ListTables API to get a response of all tables and their available properties.
    @Sendable
    @inlinable
    public func createExport(_ input: CreateExportRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> CreateExportResponse {
        try await self.client.execute(
            operation: "CreateExport", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Creates a data export and specifies the data query, the delivery preference, and any optional resource tags. A DataQuery consists of both a QueryStatement and TableConfigurations. The QueryStatement is an SQL statement. Data Exports only supports a limited subset of the SQL syntax. For more information on the SQL syntax that is supported, see Data query. To view the available tables and columns, see the Data Exports table dictionary. The TableConfigurations is a collection of specified TableProperties for the table being queried in the QueryStatement. TableProperties are additional configurations you can provide to change the data and schema of a table. Each table can have different TableProperties. However, tables are not required to have any TableProperties. Each table property has a default value that it assumes if not specified. For more information on table configurations, see Data query. To view the table properties available for each table, see the Data Exports table dictionary or use the ListTables API to get a response of all tables and their available properties.
    ///
    /// Parameters:
    ///   - export: The details of the export, including data query, name, description, and destination configuration.
    ///   - resourceTags: An optional list of tags to associate with the specified export. Each tag consists of a key and a value, and each key must be unique for the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func createExport(
        export: Export,
        resourceTags: [ResourceTag]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> CreateExportResponse {
        let input = CreateExportRequest(
            export: export, 
            resourceTags: resourceTags
        )
        return try await self.createExport(input, logger: logger)
    }

    /// Deletes an existing data export.
    @Sendable
    @inlinable
    public func deleteExport(_ input: DeleteExportRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DeleteExportResponse {
        try await self.client.execute(
            operation: "DeleteExport", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Deletes an existing data export.
    ///
    /// Parameters:
    ///   - exportArn: The Amazon Resource Name (ARN) for this export.
    ///   - logger: Logger use during operation
    @inlinable
    public func deleteExport(
        exportArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DeleteExportResponse {
        let input = DeleteExportRequest(
            exportArn: exportArn
        )
        return try await self.deleteExport(input, logger: logger)
    }

    /// Exports data based on the source data update.
    @Sendable
    @inlinable
    public func getExecution(_ input: GetExecutionRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetExecutionResponse {
        try await self.client.execute(
            operation: "GetExecution", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Exports data based on the source data update.
    ///
    /// Parameters:
    ///   - executionId: The ID for this specific execution.
    ///   - exportArn: The Amazon Resource Name (ARN) of the Export object that generated this specific execution.
    ///   - logger: Logger use during operation
    @inlinable
    public func getExecution(
        executionId: String,
        exportArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetExecutionResponse {
        let input = GetExecutionRequest(
            executionId: executionId, 
            exportArn: exportArn
        )
        return try await self.getExecution(input, logger: logger)
    }

    /// Views the definition of an existing data export.
    @Sendable
    @inlinable
    public func getExport(_ input: GetExportRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetExportResponse {
        try await self.client.execute(
            operation: "GetExport", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Views the definition of an existing data export.
    ///
    /// Parameters:
    ///   - exportArn: The Amazon Resource Name (ARN) for this export.
    ///   - logger: Logger use during operation
    @inlinable
    public func getExport(
        exportArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetExportResponse {
        let input = GetExportRequest(
            exportArn: exportArn
        )
        return try await self.getExport(input, logger: logger)
    }

    /// Returns the metadata for the specified table and table properties. This includes the list of columns in the table schema, their data types, and column descriptions.
    @Sendable
    @inlinable
    public func getTable(_ input: GetTableRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetTableResponse {
        try await self.client.execute(
            operation: "GetTable", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns the metadata for the specified table and table properties. This includes the list of columns in the table schema, their data types, and column descriptions.
    ///
    /// Parameters:
    ///   - tableName: The name of the table.
    ///   - tableProperties: TableProperties are additional configurations you can provide to change the data and schema of a table. Each table can have different TableProperties. Tables are not required to have any TableProperties. Each table property has a default value that it assumes if not specified.
    ///   - logger: Logger use during operation
    @inlinable
    public func getTable(
        tableName: String,
        tableProperties: [String: String]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetTableResponse {
        let input = GetTableRequest(
            tableName: tableName, 
            tableProperties: tableProperties
        )
        return try await self.getTable(input, logger: logger)
    }

    /// Lists the historical executions for the export.
    @Sendable
    @inlinable
    public func listExecutions(_ input: ListExecutionsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListExecutionsResponse {
        try await self.client.execute(
            operation: "ListExecutions", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Lists the historical executions for the export.
    ///
    /// Parameters:
    ///   - exportArn: The Amazon Resource Name (ARN) for this export.
    ///   - maxResults: The maximum number of objects that are returned for the request.
    ///   - nextToken: The token to retrieve the next set of results.
    ///   - logger: Logger use during operation
    @inlinable
    public func listExecutions(
        exportArn: String,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListExecutionsResponse {
        let input = ListExecutionsRequest(
            exportArn: exportArn, 
            maxResults: maxResults, 
            nextToken: nextToken
        )
        return try await self.listExecutions(input, logger: logger)
    }

    /// Lists all data export definitions.
    @Sendable
    @inlinable
    public func listExports(_ input: ListExportsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListExportsResponse {
        try await self.client.execute(
            operation: "ListExports", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Lists all data export definitions.
    ///
    /// Parameters:
    ///   - maxResults: The maximum number of objects that are returned for the request.
    ///   - nextToken: The token to retrieve the next set of results.
    ///   - logger: Logger use during operation
    @inlinable
    public func listExports(
        maxResults: Int? = nil,
        nextToken: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListExportsResponse {
        let input = ListExportsRequest(
            maxResults: maxResults, 
            nextToken: nextToken
        )
        return try await self.listExports(input, logger: logger)
    }

    /// Lists all available tables in data exports.
    @Sendable
    @inlinable
    public func listTables(_ input: ListTablesRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListTablesResponse {
        try await self.client.execute(
            operation: "ListTables", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Lists all available tables in data exports.
    ///
    /// Parameters:
    ///   - maxResults: The maximum number of objects that are returned for the request.
    ///   - nextToken: The token to retrieve the next set of results.
    ///   - logger: Logger use during operation
    @inlinable
    public func listTables(
        maxResults: Int? = nil,
        nextToken: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListTablesResponse {
        let input = ListTablesRequest(
            maxResults: maxResults, 
            nextToken: nextToken
        )
        return try await self.listTables(input, logger: logger)
    }

    /// List tags associated with an existing data export.
    @Sendable
    @inlinable
    public func listTagsForResource(_ input: ListTagsForResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListTagsForResourceResponse {
        try await self.client.execute(
            operation: "ListTagsForResource", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// List tags associated with an existing data export.
    ///
    /// Parameters:
    ///   - maxResults: The maximum number of objects that are returned for the request.
    ///   - nextToken: The token to retrieve the next set of results.
    ///   - resourceArn: The unique identifier for the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func listTagsForResource(
        maxResults: Int? = nil,
        nextToken: String? = nil,
        resourceArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListTagsForResourceResponse {
        let input = ListTagsForResourceRequest(
            maxResults: maxResults, 
            nextToken: nextToken, 
            resourceArn: resourceArn
        )
        return try await self.listTagsForResource(input, logger: logger)
    }

    /// Adds tags for an existing data export definition.
    @Sendable
    @inlinable
    public func tagResource(_ input: TagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> TagResourceResponse {
        try await self.client.execute(
            operation: "TagResource", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Adds tags for an existing data export definition.
    ///
    /// Parameters:
    ///   - resourceArn: The unique identifier for the resource.
    ///   - resourceTags: The tags to associate with the resource. Each tag consists of a key and a value, and each key must be unique for the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func tagResource(
        resourceArn: String,
        resourceTags: [ResourceTag],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> TagResourceResponse {
        let input = TagResourceRequest(
            resourceArn: resourceArn, 
            resourceTags: resourceTags
        )
        return try await self.tagResource(input, logger: logger)
    }

    /// Deletes tags associated with an existing data export definition.
    @Sendable
    @inlinable
    public func untagResource(_ input: UntagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UntagResourceResponse {
        try await self.client.execute(
            operation: "UntagResource", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Deletes tags associated with an existing data export definition.
    ///
    /// Parameters:
    ///   - resourceArn: The unique identifier for the resource.
    ///   - resourceTagKeys: The tag keys that are associated with the resource ARN.
    ///   - logger: Logger use during operation
    @inlinable
    public func untagResource(
        resourceArn: String,
        resourceTagKeys: [String],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UntagResourceResponse {
        let input = UntagResourceRequest(
            resourceArn: resourceArn, 
            resourceTagKeys: resourceTagKeys
        )
        return try await self.untagResource(input, logger: logger)
    }

    /// Updates an existing data export by overwriting all export parameters. All export parameters must be provided in the UpdateExport request.
    @Sendable
    @inlinable
    public func updateExport(_ input: UpdateExportRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UpdateExportResponse {
        try await self.client.execute(
            operation: "UpdateExport", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Updates an existing data export by overwriting all export parameters. All export parameters must be provided in the UpdateExport request.
    ///
    /// Parameters:
    ///   - export: The name and query details for the export.
    ///   - exportArn: The Amazon Resource Name (ARN) for this export.
    ///   - logger: Logger use during operation
    @inlinable
    public func updateExport(
        export: Export,
        exportArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UpdateExportResponse {
        let input = UpdateExportRequest(
            export: export, 
            exportArn: exportArn
        )
        return try await self.updateExport(input, logger: logger)
    }
}

extension BCMDataExports {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: BCMDataExports, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension BCMDataExports {
    /// Return PaginatorSequence for operation ``listExecutions(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listExecutionsPaginator(
        _ input: ListExecutionsRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListExecutionsRequest, ListExecutionsResponse> {
        return .init(
            input: input,
            command: self.listExecutions,
            inputKey: \ListExecutionsRequest.nextToken,
            outputKey: \ListExecutionsResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listExecutions(_:logger:)``.
    ///
    /// - Parameters:
    ///   - exportArn: The Amazon Resource Name (ARN) for this export.
    ///   - maxResults: The maximum number of objects that are returned for the request.
    ///   - logger: Logger used for logging
    @inlinable
    public func listExecutionsPaginator(
        exportArn: String,
        maxResults: Int? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListExecutionsRequest, ListExecutionsResponse> {
        let input = ListExecutionsRequest(
            exportArn: exportArn, 
            maxResults: maxResults
        )
        return self.listExecutionsPaginator(input, logger: logger)
    }

    /// Return PaginatorSequence for operation ``listExports(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listExportsPaginator(
        _ input: ListExportsRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListExportsRequest, ListExportsResponse> {
        return .init(
            input: input,
            command: self.listExports,
            inputKey: \ListExportsRequest.nextToken,
            outputKey: \ListExportsResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listExports(_:logger:)``.
    ///
    /// - Parameters:
    ///   - maxResults: The maximum number of objects that are returned for the request.
    ///   - logger: Logger used for logging
    @inlinable
    public func listExportsPaginator(
        maxResults: Int? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListExportsRequest, ListExportsResponse> {
        let input = ListExportsRequest(
            maxResults: maxResults
        )
        return self.listExportsPaginator(input, logger: logger)
    }

    /// Return PaginatorSequence for operation ``listTables(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listTablesPaginator(
        _ input: ListTablesRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListTablesRequest, ListTablesResponse> {
        return .init(
            input: input,
            command: self.listTables,
            inputKey: \ListTablesRequest.nextToken,
            outputKey: \ListTablesResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listTables(_:logger:)``.
    ///
    /// - Parameters:
    ///   - maxResults: The maximum number of objects that are returned for the request.
    ///   - logger: Logger used for logging
    @inlinable
    public func listTablesPaginator(
        maxResults: Int? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListTablesRequest, ListTablesResponse> {
        let input = ListTablesRequest(
            maxResults: maxResults
        )
        return self.listTablesPaginator(input, logger: logger)
    }
}

extension BCMDataExports.ListExecutionsRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> BCMDataExports.ListExecutionsRequest {
        return .init(
            exportArn: self.exportArn,
            maxResults: self.maxResults,
            nextToken: token
        )
    }
}

extension BCMDataExports.ListExportsRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> BCMDataExports.ListExportsRequest {
        return .init(
            maxResults: self.maxResults,
            nextToken: token
        )
    }
}

extension BCMDataExports.ListTablesRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> BCMDataExports.ListTablesRequest {
        return .init(
            maxResults: self.maxResults,
            nextToken: token
        )
    }
}
